import axios from 'axios'
import router from '@/router'
import Cookies from 'js-cookie'


const BASE_URL = "https://www.lvfeiy.com"
const BASE_URL2 = "http://127.0.0.1"
const instance = axios.create({
    baseURL: BASE_URL2,
    timeout: 10000
})

// instance.interceptors.request.use(
//     (config)=>{

//     }
// )

instance.interceptors.response.use(
    res => {
        console.log * ('axios守卫')
        let code = res.data.code;
        if (code === 403 || code === 401) {
            // console.log(res.data)
            // ElMessage.error(res.data.msg);
            Cookies.remove('IM-token');
            router.push('/login')

        }
        return res;


    }
)

export default instance;
export { BASE_URL };